package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcHuaLongMedicRecordMapper;
import com.csun.cmny.provider.dto.HuaLongMedicRecordQueryDto;
import com.csun.cmny.provider.model.domain.OmcHuaLongMedicRecord;
import com.csun.cmny.provider.service.OmcHuaLongMedicRecordService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2020-11-09 10:39
 * @Description:
 */
@Service
@Transactional
public class OmcHuaLongMedicRecordServiceImpl extends BaseService<OmcHuaLongMedicRecord> implements OmcHuaLongMedicRecordService {

    @Resource
    private OmcHuaLongMedicRecordMapper omcHuaLongMedicRecordMapper;

    /**
     * 保存发药记录
     *
     * @param omcHuaLongMedicRecord the omc hua long medic record
     * @param loginAuthDto          the login auth dto
     *
     * @return the int.
     */
    @Override
    public Integer save(OmcHuaLongMedicRecord omcHuaLongMedicRecord, LoginAuthDto loginAuthDto) {

        omcHuaLongMedicRecord.setGroupId(loginAuthDto.getGroupId());
        omcHuaLongMedicRecord.setUpdateInfo(loginAuthDto);

        return omcHuaLongMedicRecordMapper.insertSelective(omcHuaLongMedicRecord);
    }

    /**
     * 查询发药单列表
     *
     * @param huaLongMedicRecordQueryDto the hua long medic record query dto
     *
     * @return the list omc hua long medic record
     */
    @Override
    public List<OmcHuaLongMedicRecord> queryListWithPage(HuaLongMedicRecordQueryDto huaLongMedicRecordQueryDto) {

        PageHelper.startPage(huaLongMedicRecordQueryDto.getPageNum(), huaLongMedicRecordQueryDto.getPageSize());

        return omcHuaLongMedicRecordMapper.queryListWithPage(huaLongMedicRecordQueryDto);
    }
}
